import {NextFunction, Request, Response} from "express";
import * as express from "express";
const app = express()

// 封装一个拥有通用响应错误结果的中间件
export default function sendHandler() {
  app.use((req:Request,res:Response, next: NextFunction) => {
    //  1 缺失参数
    res.cc = (num:number) => {
      return res.send({
        code: 400,
        msg: num === 1 ? '缺少必填参数！' : ''
      })
    }
    next()
  })
}
